package com.atguigu.springcloud.service.impl;

import cn.hutool.core.util.IdUtil;
import com.atguigu.springcloud.service.IMessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;

/**
 * @PROJECT_NAME: cloud2020
 * @DESCRIPTION:
 * @Author: csc
 * @DATE: 2023/3/28 14:05
 */
@EnableBinding(Source.class)//定义消息的推送管道
public class MessageProviderImpl implements IMessageProvider
{
    /**
     * 消息发送管道
     */
   @Resource
   private MessageChannel output;


    @Override
    public String send()
    {
        String s = IdUtil.simpleUUID();
        output.send(MessageBuilder.withPayload(s).build());
        System.out.println("****serial:"+s);
        return null;
    }



}
